
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>5.3 NFS卷 · Kubernetes - 痴者工良</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="痴者工良">
        
        
    
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="4.pv_pvc.html" />
    
    
    <link rel="prev" href="2.secret_configmap.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://www.whuanle.cn" target="_blank" class="custom-link">痴者工良的博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    文档说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../1.basic/">
            
                <a href="../1.basic/">
            
                    
                    1.基础知识
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../1.basic/">
            
                <a href="../1.basic/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../1.basic/1.docker.html">
            
                <a href="../1.basic/1.docker.html">
            
                    
                    1.1 说透 Docker：基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../1.basic/2.virtual.html">
            
                <a href="../1.basic/2.virtual.html">
            
                    
                    1.2 说透 Docker： 虚拟化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../1.basic/3.docker_network.html">
            
                <a href="../1.basic/3.docker_network.html">
            
                    
                    1.3 了解 Docker 网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../1.basic/4.pod_docker.html">
            
                <a href="../1.basic/4.pod_docker.html">
            
                    
                    1.4 Docker 和 Pod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../1.basic/5.k8s.html">
            
                <a href="../1.basic/5.k8s.html">
            
                    
                    1.5 K8S入门基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../2.deploy/">
            
                <a href="../2.deploy/">
            
                    
                    2.部署和配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../2.deploy/2.deploy.md">
            
                <span>
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../2.deploy/1.minikube.html">
            
                <a href="../2.deploy/1.minikube.html">
            
                    
                    2.1 使用 Minikube 部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../2.deploy/2.kubeadm.html">
            
                <a href="../2.deploy/2.kubeadm.html">
            
                    
                    2.2 使用 kubeadm 部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../2.deploy/3.kubeadm_ckad.html">
            
                <a href="../2.deploy/3.kubeadm_ckad.html">
            
                    
                    2.3 CKAD认证中的部署教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../2.deploy/4.kubeadm_proxy.html">
            
                <a href="../2.deploy/4.kubeadm_proxy.html">
            
                    
                    2.4 国内代理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../2.deploy/5.dashboard.html">
            
                <a href="../2.deploy/5.dashboard.html">
            
                    
                    2.5 Dashboard
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../3.pod/">
            
                <a href="../3.pod/">
            
                    
                    3.Pod部署和调度
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../3.pod/">
            
                <a href="../3.pod/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../3.pod/1.pod.html">
            
                <a href="../3.pod/1.pod.html">
            
                    
                    3.1 Pod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../3.pod/2.deployment.html">
            
                <a href="../3.pod/2.deployment.html">
            
                    
                    3.2 Deployment部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../3.pod/3.replica.html">
            
                <a href="../3.pod/3.replica.html">
            
                    
                    3.3 副本集(ReplicaSet)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../3.pod/4.pod_network.html">
            
                <a href="../3.pod/4.pod_network.html">
            
                    
                    3.34 Pod 端口映射
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../3.pod/5.update.html">
            
                <a href="../3.pod/5.update.html">
            
                    
                    3.5 Pod 升级、回滚
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../3.pod/6.scale.html">
            
                <a href="../3.pod/6.scale.html">
            
                    
                    3.6 Pod 缩放
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../3.pod/7.lable.html">
            
                <a href="../3.pod/7.lable.html">
            
                    
                    3.7.Pod 标签
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../3.pod/8.schedule.html">
            
                <a href="../3.pod/8.schedule.html">
            
                    
                    3.8 Pod 调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../3.pod/9.jobs_cronjobs.html">
            
                <a href="../3.pod/9.jobs_cronjobs.html">
            
                    
                    3.9 Jobs、CronJobs
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../4.network/">
            
                <a href="../4.network/">
            
                    
                    4.Kubernetes 网络
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../4.network/">
            
                <a href="../4.network/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../4.network/1.network.html">
            
                <a href="../4.network/1.network.html">
            
                    
                    4.1 Kubernetes 网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../4.network/2.endpoint.html">
            
                <a href="../4.network/2.endpoint.html">
            
                    
                    4.2 Endpoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../4.network/3.ingress.html">
            
                <a href="../4.network/3.ingress.html">
            
                    
                    4.3 ingress
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../4.network/4.discovery.html">
            
                <a href="../4.network/4.discovery.html">
            
                    
                    4.4 服务发现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="./">
            
                <a href="./">
            
                    
                    5.volumes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="./">
            
                <a href="./">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="1.volumes.html">
            
                <a href="1.volumes.html">
            
                    
                    5.1 卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="2.secret_configmap.html">
            
                <a href="2.secret_configmap.html">
            
                    
                    5.2 secret 和 ConfigMap 卷
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6.4" data-path="3.nfts.html">
            
                <a href="3.nfts.html">
            
                    
                    5.3 NFS卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="4.pv_pvc.html">
            
                <a href="4.pv_pvc.html">
            
                    
                    5.4 持久化卷
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../6.api_safe/">
            
                <a href="../6.api_safe/">
            
                    
                    6.API 和 安全
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../6.api_safe/">
            
                <a href="../6.api_safe/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../7.health/">
            
                <a href="../7.health/">
            
                    
                    7.维护和故障排除
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../8.health/README.md">
            
                <span>
            
                    
                    导读
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../k8s.html">
            
                <a href="../k8s.html">
            
                    
                    Kubernetes 命令概览
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../ckad.html">
            
                <a href="../ckad.html">
            
                    
                    CKAD 认证帮助
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >5.3 NFS卷</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#53-nfs&#x5377;"><b></b>5.3 NFS&#x5377;</a></li><ul><li><span class="title-icon "></span><a href="#&#x642D;&#x5EFA;-nfs-&#x670D;&#x52A1;"><b></b>&#x642D;&#x5EFA; NFS &#x670D;&#x52A1;</a></li><ul><li><span class="title-icon "></span><a href="#nfs-&#x670D;&#x52A1;"><b></b>nfs &#x670D;&#x52A1;</a></li><li><span class="title-icon "></span><a href="#nfs-&#x5BA2;&#x6237;&#x7AEF;"><b></b>nfs &#x5BA2;&#x6237;&#x7AEF;</a></li><li><span class="title-icon "></span><a href="#&#x6302;&#x8F7D;&#x5230;-pod"><b></b>&#x6302;&#x8F7D;&#x5230; Pod</a></li></ul></ul></ul></div><h1 id="53-nfs&#x5377;"><a name="53-nfs&#x5377;" class="anchor-navigation-ex-anchor" href="#53-nfs&#x5377;"><i class="fa fa-link" aria-hidden="true"></i></a>5.3 NFS&#x5377;</h1>
<p>NFS &#x5377;&#xFF0C;&#x53EF;&#x4EE5;&#x628A;&#x5B83;&#x60F3;&#x8C61;&#x6210;&#x4E91;&#x786C;&#x76D8;&#xFF0C;&#x968F;&#x65F6;&#x53EF;&#x4EE5;&#x6302;&#x8F7D;&#x5230;&#x670D;&#x52A1;&#x5668;&#x7684;&#x4EFB;&#x610F;&#x76EE;&#x5F55;&#xFF0C;&#x800C;&#x4E14;&#x591A;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x53EF;&#x4EE5;&#x540C;&#x65F6;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x5377;&#x3002;</p>
<p><img src="images/image-20211109212928180.png" alt="image-20211109212928180"></p>
<p>&#x5728;&#x524D;&#x9762;&#xFF0C;&#x6211;&#x4EEC;&#x5B66;&#x4E60;&#x4E86; emptyDir&#x3001;hostPath &#x7B49;&#x5377;&#xFF0C;&#x8FD9;&#x4E9B;&#x5377;&#x90FD;&#x6709;&#x5404;&#x81EA;&#x7684;&#x5E94;&#x7528;&#x573A;&#x666F;&#xFF0C;&#x521B;&#x5EFA;&#x4E5F;&#x5F88;&#x65B9;&#x4FBF;&#x3002;&#x4F46;&#x662F;&#x8FD9;&#x4E9B;&#x5377;&#x90FD;&#x4E0D;&#x80FD;&#x4E3A;&#x591A;&#x8282;&#x70B9;&#x4E2D;&#x7684; Pod &#x63D0;&#x4F9B;&#x5B58;&#x50A8;&#x7A7A;&#x95F4;&#xFF0C;&#x5F53; Pod &#x7684;&#x526F;&#x672C;&#x5728;&#x4E0D;&#x540C;&#x8282;&#x70B9;&#x4E2D;&#x8FD0;&#x884C;&#x65F6;&#xFF0C;&#x65E0;&#x6CD5;&#x901A;&#x8FC7;&#x8FD9;&#x4E9B;&#x5377;&#x4E3A;&#x6240;&#x6709;&#x7684; Pod &#x63D0;&#x4F9B;&#x4E00;&#x81F4;&#x7684;&#x6587;&#x4EF6;&#x5185;&#x5BB9;&#xFF1B;&#x540E;&#x7EED;&#x5982;&#x679C;&#x7A0B;&#x5E8F;&#x4FEE;&#x6539;&#x4E86;&#x5377;&#x4E2D;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x4E5F;&#x65E0;&#x6CD5;&#x540C;&#x6B65;&#x64CD;&#x4F5C;&#x5230;&#x6240;&#x6709; Pod &#x4E2D;&#x3002;</p>
<p>NFS &#x662F;&#x4E00;&#x79CD;&#x7F51;&#x7EDC;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#xFF0C;&#x82F1;&#x6587; Network File System(NFS)&#xFF0C;&#x80FD;&#x4F7F;&#x4F7F;&#x7528;&#x8005;&#x8BBF;&#x95EE;&#x7F51;&#x7EDC;&#x4E0A;&#x522B;&#x5904;&#x7684;&#x6587;&#x4EF6;&#x5C31;&#x50CF;&#x5728;&#x4F7F;&#x7528;&#x81EA;&#x5DF1;&#x7684;&#x8BA1;&#x7B97;&#x673A;&#x4E00;&#x6837;&#xFF0C;NFS &#x53EF;&#x4EE5;&#x72EC;&#x7ACB;&#x4E8E;&#x96C6;&#x7FA4;&#x4E2D;&#x7684;&#x8282;&#x70B9;&#xFF0C;&#x5176;&#x5B58;&#x50A8;&#x7A7A;&#x95F4;&#x53EF;&#x4EE5;&#x5728;&#x96C6;&#x7FA4;&#x4E4B;&#x5916;&#xFF0C;&#x7136;&#x540E;&#x901A;&#x8FC7;&#x7F51;&#x7EDC;&#x4E3A;&#x591A;&#x4E2A;&#x8282;&#x70B9;&#x5171;&#x4EAB;&#x6587;&#x4EF6;&#x3002;&#x4E0D;&#x540C;&#x7684;&#x8282;&#x70B9;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8FDC;&#x7A0B;&#x5B58;&#x53D6;&#x3001;&#x64CD;&#x4F5C;&#x6587;&#x4EF6;&#xFF0C;&#x540C;&#x65F6;&#x6587;&#x4EF6;&#x7684;&#x72B6;&#x6001;&#x4E3A;&#x6240;&#x6709;&#x8282;&#x70B9;&#x5171;&#x4EAB;&#xFF0C;&#x4FDD;&#x8BC1;&#x6BCF;&#x4E2A;&#x8282;&#x70B9;&#x4E0A;&#x8BBF;&#x95EE;&#x5230;&#x7684;&#x6587;&#x4EF6;&#x5185;&#x5BB9;&#x3001;&#x72B6;&#x6001;&#x90FD;&#x662F;&#x4E00;&#x81F4;&#x7684;&#x3001;&#x5B9E;&#x65F6;&#x7684;&#x3002;</p>
<p>NFS &#x662F;&#x57FA;&#x4E8E; UDP/IP &#x534F;&#x8BAE;&#x7684;&#x5E94;&#x7528;&#xFF0C;&#x5176;&#x5B9E;&#x73B0;&#x662F;&#x91C7;&#x7528;&#x8FDC;&#x7A0B;&#x8FC7;&#x7A0B;&#x8C03;&#x7528; RPC &#x673A;&#x5236;&#xFF0C;NFS &#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x7EC4;&#x4E0E;&#x673A;&#x5668;&#x3001;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x4EE5;&#x53CA;&#x4F4E;&#x5C42;&#x4F20;&#x9001;&#x534F;&#x8BAE;&#x65E0;&#x5173;&#x7684;&#x5B58;&#x53D6;&#x8FDC;&#x7A0B;&#x6587;&#x4EF6;&#x7684;&#x64CD;&#x4F5C;&#x3002;</p>
<p>&#x4EE5;&#x67D0;&#x4E91;&#x7684;&#x4E91;&#x786C;&#x76D8;&#x4E3A;&#x4F8B;&#xFF0C;&#x4E86;&#x89E3;&#x4E00;&#x4E0B;&#x5B83;&#x3002;</p>
<p><img src="images/t.jpg" alt="t"></p>
<h2 id="&#x642D;&#x5EFA;-nfs-&#x670D;&#x52A1;"><a name="&#x642D;&#x5EFA;-nfs-&#x670D;&#x52A1;" class="anchor-navigation-ex-anchor" href="#&#x642D;&#x5EFA;-nfs-&#x670D;&#x52A1;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x642D;&#x5EFA; NFS &#x670D;&#x52A1;</h2>
<h3 id="nfs-&#x670D;&#x52A1;"><a name="nfs-&#x670D;&#x52A1;" class="anchor-navigation-ex-anchor" href="#nfs-&#x670D;&#x52A1;"><i class="fa fa-link" aria-hidden="true"></i></a>nfs &#x670D;&#x52A1;</h3>
<p>&#x6211;&#x4EEC;&#x9996;&#x5148;&#x5728;&#x4E00;&#x53F0;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#xFF0C;&#x90E8;&#x7F72; NFS &#x670D;&#x52A1;&#xFF0C;&#x7531;&#x4E8E;&#x8FD9;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x5BF9;&#x6240;&#x6709;&#x8282;&#x70B9;&#x63D0;&#x4F9B;&#x4E86;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#xFF0C;&#x6240;&#x4EE5;&#x8FD9;&#x53F0;&#x670D;&#x52A1;&#x5668;&#x7684;&#x786C;&#x76D8;&#x9700;&#x8981;&#x80FD;&#x591F;&#x81EA;&#x52A8;&#x5907;&#x4EFD;&#x3001;&#x5B95;&#x673A;&#x4FDD;&#x62A4;&#x7B49;&#xFF0C;&#x4FDD;&#x8BC1;&#x6570;&#x636E;&#x5B89;&#x5168;&#x3002;</p>
<p>&#x7B14;&#x8005;&#x5EFA;&#x8BAE;&#x662F; master &#x8282;&#x70B9;&#x521B;&#x5EFA; nfs &#x670D;&#x52A1;&#xFF0C;worker &#x8282;&#x70B9;&#x4F7F;&#x7528; nfs &#x670D;&#x52A1;&#x3002;</p>
<p>&#x5728; Ubuntu &#x4E2D;&#x5B89;&#x88C5; nfs &#x5E93;&#xFF0C;&#x542F;&#x52A8; nfs &#x670D;&#x52A1;&#x3002;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">sudo</span> <span class="token function">apt-get</span> update <span class="token operator">&amp;&amp;</span> <span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> -y nfs-kernel-server
</code></pre>
<p>&#x5728;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x521B;&#x5EFA;&#x8981;&#x5171;&#x4EAB;&#x7684;&#x76EE;&#x5F55;&#x3002;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">mkdir</span> /nfs-share
<span class="token function">chmod</span> <span class="token number">777</span>  /nfs-share
<span class="token comment"># &#x968F;&#x4FBF;&#x586B;&#x5145;&#x4E00;&#x4E9B;&#x6587;&#x4EF6;</span>
<span class="token builtin class-name">echo</span> <span class="token function">env</span> <span class="token operator">&gt;</span>  /nfs-share/env.txt
</code></pre>
<p>&#x68C0;&#x67E5; nfs &#x670D;&#x52A1;&#x662F;&#x5426;&#x5DF2;&#x7ECF;&#x6B63;&#x5E38;&#x5B89;&#x88C5;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">rpcinfo -p localhost
</code></pre>
<p>&#x5BFC;&#x51FA;&#x914D;&#x7F6E;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token builtin class-name">echo</span> <span class="token string">&quot;/nfs-share *(rw,no_root_squash,sync)&quot;</span> <span class="token operator">&gt;&gt;</span> /etc/exports
</code></pre>
<p>&#x4F7F;&#x914D;&#x7F6E;&#x751F;&#x6548;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">exportfs -r
</code></pre>
<p>&#x68C0;&#x67E5;&#x662F;&#x5426;&#x5DF2;&#x7ECF;&#x751F;&#x6548;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">exportfs
</code></pre>
<p>&#x542F;&#x52A8; rpcbind&#x3001;nfs &#x670D;&#x52A1;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">systemctl restart rpcbind 
systemctl <span class="token builtin class-name">enable</span> rpcbind
systemctl restart nfs 
systemctl <span class="token builtin class-name">enable</span> nfs
</code></pre>
<p>&#x63A5;&#x4E0B;&#x6765;&#x53EF;&#x4EE5;&#x5728;&#x672C;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x6D4B;&#x8BD5;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">showmount -e <span class="token variable"><span class="token variable">$(</span><span class="token function">hostname</span> -i<span class="token variable">)</span></span>
<span class="token comment"># &#x6216;&#x8005; showmount -e 127.0.0.1</span>
</code></pre>
<pre class="language-"><code class="lang-bash">Export list <span class="token keyword">for</span> <span class="token number">10.170</span>.0.2:
/nfs-share *
</code></pre>
<h3 id="nfs-&#x5BA2;&#x6237;&#x7AEF;"><a name="nfs-&#x5BA2;&#x6237;&#x7AEF;" class="anchor-navigation-ex-anchor" href="#nfs-&#x5BA2;&#x6237;&#x7AEF;"><i class="fa fa-link" aria-hidden="true"></i></a>nfs &#x5BA2;&#x6237;&#x7AEF;</h3>
<p>&#x5728;&#x53E6;&#x4E00;&#x53F0;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x5B89;&#x88C5; nfs &#x5BA2;&#x6237;&#x7AEF;&#x3002;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">apt</span> <span class="token function">install</span> nfs-common
</code></pre>
<p>&#x6302;&#x8F7D; nfs &#x670D;&#x52A1;&#x5668;&#x7684;&#x76EE;&#x5F55;&#x5230;&#x672C;&#x5730;&#x4E2D;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">mount</span> <span class="token punctuation">{</span>&#x90E8;&#x7F72;&#x4E86;nfs&#x670D;&#x52A1;&#x5668;&#x7684;ip<span class="token punctuation">}</span>:/nfs-share /mnt
</code></pre>
<p>&#x67E5;&#x770B;&#x6302;&#x8F7D;&#x7684;&#x76EE;&#x5F55;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">ls</span> -lah /mnt
total 12K
drwxrwxrwx  <span class="token number">2</span> root root <span class="token number">4</span>.0K May  <span class="token number">1</span> 02:36 <span class="token builtin class-name">.</span>
drwxr-xr-x <span class="token number">24</span> root root <span class="token number">4</span>.0K May  <span class="token number">1</span> 02:35 <span class="token punctuation">..</span>
-rw-r--r--  <span class="token number">1</span> root root    <span class="token number">4</span> May  <span class="token number">1</span> 02:36 env.txt
</code></pre>
<p>&#x8BF4;&#x660E;&#x6211;&#x4EEC;&#x7684;&#x914D;&#x7F6E;&#x6CA1;&#x6709;&#x95EE;&#x9898;&#xFF0C;&#x73B0;&#x5728;&#x662F;&#x6302;&#x8F7D;&#x5230;&#x4E3B;&#x673A;&#x7684;&#x76EE;&#x5F55;&#x3002;&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x5C06; NFS &#x5377;&#x6302;&#x8F7D;&#x5230; Pod &#x4E2D;&#x3002;</p>
<h3 id="&#x6302;&#x8F7D;&#x5230;-pod"><a name="&#x6302;&#x8F7D;&#x5230;-pod" class="anchor-navigation-ex-anchor" href="#&#x6302;&#x8F7D;&#x5230;-pod"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6302;&#x8F7D;&#x5230; Pod</h3>
<p>&#x6A21;&#x677F;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">apiVersion</span><span class="token punctuation">:</span> v1
<span class="token key atrule">kind</span><span class="token punctuation">:</span> Pod
<span class="token key atrule">metadata</span><span class="token punctuation">:</span>
  <span class="token key atrule">name</span><span class="token punctuation">:</span> nginx
<span class="token key atrule">spec</span><span class="token punctuation">:</span>
  <span class="token key atrule">containers</span><span class="token punctuation">:</span>
    <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> nginx
      <span class="token key atrule">image</span><span class="token punctuation">:</span> nginx<span class="token punctuation">:</span>latest
      <span class="token key atrule">volumeMounts</span><span class="token punctuation">:</span>
        <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> mynfs
          <span class="token key atrule">mountPath</span><span class="token punctuation">:</span> /mnt/mynfs
  <span class="token key atrule">volumes</span><span class="token punctuation">:</span>
    <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> mynfs
      <span class="token key atrule">nfs</span><span class="token punctuation">:</span>
        <span class="token key atrule">server</span><span class="token punctuation">:</span> 10.170.0.2
        <span class="token key atrule">path</span><span class="token punctuation">:</span> /nfs<span class="token punctuation">-</span>share
</code></pre>
<pre class="language-"><code class="lang-bash">kubectl apply -f nginx.yaml
</code></pre>
<p>&#x67E5;&#x770B;&#x5BB9;&#x5668;&#x4E2D;&#x7684; <code>/mnt/mynfs</code> &#x76EE;&#x5F55;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl <span class="token builtin class-name">exec</span> nginx -- <span class="token function">ls</span> /mnt/mynfs
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; &#x75F4;&#x8005;&#x5DE5;&#x826F; 2021 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x6587;&#x6863;&#x6700;&#x540E;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2021-11-17 07:20:12
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="2.secret_configmap.html" class="navigation navigation-prev " aria-label="Previous page: 5.2 secret 和 ConfigMap 卷">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="4.pv_pvc.html" class="navigation navigation-next " aria-label="Next page: 5.4 持久化卷">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"5.3 NFS卷","level":"1.6.4","depth":2,"next":{"title":"5.4 持久化卷","level":"1.6.5","depth":2,"path":"5.volumes/4.pv_pvc.md","ref":"5.volumes/4.pv_pvc.md","articles":[]},"previous":{"title":"5.2 secret 和 ConfigMap 卷","level":"1.6.3","depth":2,"path":"5.volumes/2.secret_configmap.md","ref":"5.volumes/2.secret_configmap.md","articles":[]},"dir":"ltr"},"config":{"plugins":["tbfed-pagefooter","anchor-navigation-ex","mermaid-gb3","insert-logo","chapter-fold","advanced-emoji","github","splitter","alerts","popup","prism","-highlight","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy 痴者工良 2021","modify_label":"文档最后更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"prism":{"lang":{"flow":"typescript","shell":"bash"},"ignore":["mermaid","eval-js"],"css":["prismjs/themes/prism.css"],"js":["prismjs/prism.js","prismjs/components.js","prismjs/components/prism-go.min.js","prismjs/components/prism-yaml.min.js","prismjs/components/prism-bash.min.js","prismjs/components/prism-shell-session.min.js"]},"github":{"url":"https://github.com/whuanle/kubernetes"},"livereload":{},"splitter":{},"search":{},"popup":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"mermaid-gb3":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":false,"showLevel":false},"alerts":{},"advanced-emoji":{"embedEmojis":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"insert-logo":{"style":"background: none; max-height: 50px; min-height: 50px","url":"/images/logo.jpg"}},"theme":"default","author":"痴者工良","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Kubernetes - 痴者工良","language":"zh-hans","links":{"sidebar":{"痴者工良的博客":"https://www.whuanle.cn"}},"gitbook":"*","description":"这是一本关于 Kubernetes 的书，作者 痴者工良"},"file":{"path":"5.volumes/3.nfts.md","mtime":"2021-11-16T23:20:12.523Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-11-16T23:21:22.294Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

